package org.tp;

import java.io.FileReader;
import java_cup.runtime.Symbol;
import java.util.*;
public class Main {

	static VarLocImp current;
	//static VarLocImp oldCurrent;
	static VarGlob varGlob;
	//static VarGlob oldVarGlob;
	static ListeFonction fonctions;
	//static ListeFonction oldFonctions;
	static ListeClasse listClass;
	static Struct structDecla;
	//static Struct oldStruct;
	static Typedef typedef;



	public static void main(String[] args) {
		try {
			varGlob=new VarGlob();	 
			current=new VarLocImp();
			structDecla = new Struct();
			listClass = new ListeClasse();
			fonctions = new ListeFonction();
			typedef=new Typedef();
			FileReader  myFile = new FileReader(args[0]);
			TpLexer myLex = new TpLexer(myFile);
			TpParser myP = new TpParser(myLex);
			Symbol result=null;

			try {
				result=myP.parse();
				try {
					AbSynt root=(AbSynt)result.value;
					//System.out.println(root.toString());
					//root.toDot("ABSYNT");

					root.ecrireAbSynt();

				}	
				catch (Exception e) {
					System.out.println("result error");
				}
			}
			catch (Exception e) {
				System.out.println("Result parse error...");
			}
		}
		catch (Exception e){
			System.out.println("invalid file");	    
		}
	}
}
